package com.hnevc.lirihui;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class Item extends AppCompatActivity {

    private ListView mLv1;
    private  String[] tv_title={"烤鸭","回锅肉","茄子","宫保鸡丁"};
    private  String[] tv_item={"烤鸭烤鸭烤鸭烤鸭烤鸭烤鸭烤鸭烤鸭","回锅肉回锅肉回锅肉回锅肉回锅肉回锅肉回锅肉回锅肉","茄子茄子茄子茄子茄子茄子茄子茄子","宫保鸡丁宫保鸡丁宫保鸡丁宫保鸡丁宫保鸡丁宫保鸡丁宫保鸡丁宫保鸡丁"};
    private  String[] tv_content={"88.0元/份","12.3元/份","1.0元/份","0.2元/份"};
    private  int[] tv_iv={R.drawable.one,R.drawable.two,R.drawable.three,R.drawable.four};
    private TextView zf_tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.item_main);
        mLv1=(ListView)findViewById(R.id.mLv1);
        MyBaseAdapter myBaseAdapter=new MyBaseAdapter();
        mLv1.setAdapter(myBaseAdapter);
        zf_tv = findViewById(R.id.zf_tv);
        zf_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =new Intent(Item.this,XqActivity.class);
                startActivity(intent);
            }
        });
    }
    class MyBaseAdapter extends BaseAdapter{

        @Override
        public int getCount() {

            return tv_title.length;
        }

        @Override
        public Object getItem(int position) {

            return tv_title[position];
        }

        @Override
        public long getItemId(int position) {

            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view =View.inflate(Item.this,R.layout.item_list,null);
            TextView titles=(TextView) view.findViewById(R.id.tv_title);
            TextView prices=(TextView) view.findViewById(R.id.tv_item);
            TextView content=(TextView) view.findViewById(R.id.tv_content);
            ImageView icons=(ImageView) view.findViewById(R.id.tv_iv);
            titles.setText(tv_title[position]);
            prices.setText(tv_item[position]);
            content.setText(tv_content[position]);
            icons.setBackgroundResource(tv_iv[position]);
            return view;

        }
    }
}
